package org.deltaset.secured.domain;

import java.io.Serializable;
import javax.validation.constraints.Size;
import java.util.Date;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.ManyToOne;
import org.deltaset.secured.user.Common;
import org.deltaset.secured.visit.Person;

@Entity
public class Visit implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long id;
    @Version
    @Column(name = "version")
    private Integer version;
    @Size(max = 255)
    private String description;
    @NotNull
    @Past
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "M-")
    private Date visitDate;
    @NotNull
    @ManyToOne
    private Pet pet;
    @ManyToOne
    private Vet vet;
    @ManyToOne
    private Person perosn;

    public Person getPerosn() {
        return perosn;
    }

    public void setPerosn(Person perosn) {
        this.perosn = perosn;
    }
    
    private Common common;

    public Common getCommon() {
        if(null==common){
            common = new Common();
        }
        return common;
    }

    public void setCommon(Common common) {
        this.common = common;
    }

    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getVisitDate() {
        return this.visitDate;
    }

    public void setVisitDate(Date visitDate) {
        this.visitDate = visitDate;
    }

    public Pet getPet() {
        return this.pet;
    }

    public void setPet(Pet pet) {
        this.pet = pet;
    }

    public Vet getVet() {
        return this.vet;
    }

    public void setVet(Vet vet) {
        this.vet = vet;
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getVersion() {
        return this.version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("Description: ").append(getDescription()).append(", ");
        sb.append("Id: ").append(getId()).append(", ");
        sb.append("Pet: ").append(getPet()).append(", ");
        sb.append("Version: ").append(getVersion()).append(", ");
        sb.append("Vet: ").append(getVet()).append(", ");
        sb.append("VisitDate: ").append(getVisitDate());
        return sb.toString();
    }
}
